package engine.j2d;

public final class Particle 
{
	public static final int LOCATION_X = 0;
	public static final int LOCATION_Y = 1;
	public static final int SPEED_X = 0;
	public static final int SPEED_Y = 1;
	
	private float lifetime;
	private float decay;
	private float location[] = { 150.0f, 150.0f};
	private float speed[] = { 0.0f, 0.0f};
	
	public Particle(float lifetime, float decay) 
	{
		this.lifetime = lifetime;
		this.decay = decay;
	}
	public float getLocation(int direction) 
	{
		return location[direction];
	}
	public float getSpeed(int direction) 
	{
		return speed[direction];
	}
	public void setSpeed(int direction, float newspeed) 
	{
		speed[direction] = newspeed;
	}
	public boolean isAlive() 
	{
		return (lifetime > 0.0);
	}
	public void kill() 
	{
		lifetime = 0.0f;
	}
	public void evolve() 
	{
		lifetime -= decay;
		for(int i=0; i<2; i++)
		location[i] += speed[i];
	}
}
